<%!
class MyJsp
{
	HttpServletRequest request;
	javax.servlet.jsp.JspWriter out;
	javax.servlet.http.HttpSession session;
	HttpServletResponse response;
	MyJsp(HttpServletRequest request,HttpServletResponse response,javax.servlet.jsp.JspWriter out,javax.servlet.http.HttpSession session)
	{
	try{
	this.request=request;
	this.out=out;
	this.response=response;
	this.session=session;
	}catch(Exception e)
	{}
	}
	
	public String cstr(String str1)
	{
		return str1==null?"":str1;
	} 
	String getSession(String s1)
	{
		String s2=(String)session.getAttribute(s1);
		if(s2==null)
		{
			return "";
		}else{
			return s2;
		}
	}
	String toChina(String s1)
	{
		try{
		String s2=new String(s1.getBytes("ISO-8859-1"),"GB2312");
		return s2;
		}catch(Exception e)
		{
			return "";
		}
	}	
	void resizeTo(String center,String w,String h)
	{
		this.jscript("window.moveTo((screen.availWidth-"+w+")/2,(screen.availHeight-"+h+")/2);");
	}
	public void jscript(String str1)
	{
		try{
		out.write("\n<script language=javascript>\n");
		out.write(str1+"\n");
		out.write("</script>\n");
		}
		catch(Exception e)
		{}
		
	}
	public void visit(String str1)
	{
		try{
		out.write("<script language=javascript>\n");
		out.write("window.navigate('"+str1+"');\n");
		out.write("</script>\n");
		}
		catch(Exception e)
		{}
		
	}
	public void back()
	{
	try{
	this.jscript("history.back();");
	}
	catch(Exception e)
	{}
	}
	public void close()
	{
		try{
		out.write("<script language=javascript>\n");
		out.write("window.opener=null;\n window.close();\n");
		out.write("</script>\n");
		}
		catch(Exception e)
		{}
	}
	public void refreshOpener()
	{
		try{
		out.write("<script language=javascript>\n");
		out.write("window.opener.location.reload();\n");
		out.write("</script>\n");
		}
		catch(Exception e)
		{}
	}
	public String r(String str1)
	{
		
		String tmpstr="";
		try
		{
		 request.setCharacterEncoding("gb2312");
		tmpstr=request.getParameter(str1);
		tmpstr=tmpstr.replaceAll("\\+","gs_plus");
		//tmpstr=tmpstr.replaceAll("\\%","gs_bfh");
		try{
		tmpstr=java.net.URLDecoder.decode(tmpstr, "UTF-8");
	}catch(Exception e1){}
		tmpstr=tmpstr.replaceAll("gs_plus","\\+");
		tmpstr=tmpstr.replaceAll("gs_bfh","\\%");
		}catch(Exception e)
		{
			//tmpstr=e.toString();
			}
		if (tmpstr==null)
		{
		return "";
		}else{
		return tmpstr;
		}
		
	}//r
	public String r2(String str1)
	{
		
		String tmpstr="";
		try
		{
		tmpstr=java.net.URLDecoder.decode(request.getParameter(str1), "UTF-8");
		}catch(Exception e)
		{}
		if (tmpstr==null)
		{
		return "";
		}else{
		return tmpstr;
		}
		
	}//r
	public void breakPage()
	{
		this.w("<div style='PAGE-BREAK-AFTER: always'></div>");
	}
	public void w(String str1)
	{
		try{
		out.write(str1);
	}
	catch(Exception e)
	{}
	}//w
	public void alert(String str1)
	{
	String str2=str1;
	str2=str2.replaceAll("\\\\","\\\\\\\\");
	str2=str2.replaceAll("\"","\\\\\"");
	str2=str2.replaceAll("\r\n","\\\\r\\\\n");
	str2=str2.replaceAll("\n","\\\\n");
	
	w( "<script language=javascript>\n alert(\""+str2+"\");\n</script>\n");
	}//msgbox
	public void setValue(String name1,String value1)
	{
	if(value1==null) value1="";
	String tmpstr="";
	tmpstr+="\n <script language=javascript> ";
	//value1=value1.replaceAll("/","\\/");
	value1=value1.replaceAll("\\\\","\\\\\\\\");
	value1=value1.replaceAll("\r\n","\\\\r\\\\n");
	value1=value1.replaceAll("\n","\\\\n");
	value1=value1.replaceAll("\r","\\\\r");
	value1=value1.replaceAll("\"","\\\\\"");
	
	tmpstr+="\n gs_setvalue(\""+name1+"\",\""+value1+"\");";
	tmpstr+="\n </script> ";
	w( tmpstr); 	
	}
	public void setValue(String name1,String value1,int row,int col)
	{
	if(value1==null) value1="";
	String tmpstr="";
	tmpstr+="\n <script language=javascript> ";
	value1=value1.replaceAll("\\\\","\\\\\\\\");
	value1=value1.replaceAll("\r\n","\\\\r\\\\n");
	value1=value1.replaceAll("\n","\\\\n");
	value1=value1.replaceAll("\"","\\\\\"");
	
	tmpstr+="\n gs_setvalue(\""+name1+"\",\""+value1+"\","+String.valueOf(row)+","+String.valueOf(col)+");";
	tmpstr+="\n </script> ";
	w( tmpstr); 	
	}

	public void removeOption(String str1)
	{
		this.jscript("remove_option('"+str1+"');");
	}
	public void addOption(String str1,String str2,String str3)
	{
		this.jscript("add_option('"+str1+"','"+str2+"','"+str3+"');");
	}
	public String dateFormat(String date1,String format1)
	{
		try{
		return new java.text.SimpleDateFormat(format1).format(new java.text.SimpleDateFormat("yyyy-MM-dd").parse(date1));
		}catch(Exception e)
		{
			return "";
		}
	}
	public String date()
	{
		
		return new java.text.SimpleDateFormat("yyyy-MM-dd").format(java.util.Calendar.getInstance().getTime());
	}
	public String dateTime()
	{
		
		return new java.text.SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(java.util.Calendar.getInstance().getTime());
	}
	public String dateTime1()
	{
		
		return new java.text.SimpleDateFormat("yyyyMMddHHmmss").format(java.util.Calendar.getInstance().getTime());
	}
	public String date01()
	{
		java.text.SimpleDateFormat f2=new java.text.SimpleDateFormat("yyyy-MM-01");
		return f2.format(new java.util.Date());
	}
	 public  boolean   fileCopy(String file1,String file2){   
  		try{   
  		String   fileName   =  file1;   
  		byte[]   iobuff   =   new   byte[1024];   
  		int   bytes;   
  		  
  		java.io.FileInputStream   fis   =   new   java.io.FileInputStream(fileName);   
  		java.io.FileOutputStream   fos   =   new   java.io.FileOutputStream(file2);   
  		  
  		while   (   (bytes   =   fis.read(iobuff))   !=   -1)   {   
  		fos.write(iobuff,   0,   bytes);   
  		}   
  		fis.close();   
  		fos.close();   
  		return true;
  		}catch(Exception   e){   
  		e.printStackTrace();  
  		return false; 
  		}   
 	 }
	public void addHead()
	{
		String str1="\n     <meta http-equiv=\"pragma\" content=\"no-cache\">                         "
				+"\n     <meta http-equiv=\"cache-control\" content=\"no-cache\">                  "
				+"\n     <meta http-equiv=\"expires\" content=\"0\">                               "
				+"\n     <meta http-equiv=\"Content-Type\" content=\"text/html; charset=gbk\" />   " 
				+"\n     <meta http-equiv=\"Page-Enter\" content=\"revealTrans(duration=1, transition="+String.valueOf((int)(Math.random()*100/4))+")\">"
				+"\n     <link href=\"/alarmBip/public/public.css\" rel=\"stylesheet\" type=\"text/css\">   "
				+"\n <script language=javascript>                                                  "
				+"\n try{                                                                          "
				+"\n endwait();                 "
				+"\n }catch(e)                                                                     "
				+"\n {}                                                                            "
				+"\n </script>";	
			this.w(str1);
		}
	public void addJS()
	{
		this.w("\n <script language=jscript src=/alarmBip/public/calendar.js></script>");
		this.w("\n <script language=jscript src=/alarmBip/public/public.js></script>");
		this.w("\n <script language=vbscript src=/alarmBip/public/xmlhttp1.js></script>");
		this.w("\n <script language=jscript src=/alarmBip/public/xmlhttp2.js></script>");
		this.w("\n<script type=\"text/javascript\" src=\"/alarmBip/includes/excanvas.js\"></script>          "); 
		this.w("\n<script type=\"text/javascript\" src=\"/alarmBip/includes/chart.js\"></script>             ");
		this.w("\n<script type=\"text/javascript\" src=\"/alarmBip/includes/canvaschartpainter.js\"></script>");
		this.w("\n<link rel=\"stylesheet\" type=\"text/css\" href=\"/alarmBip/includes/canvaschart.css\" />    ");
		}
	public boolean isMethod(String method)
		{
			if(this.r("method").equals(method))
			{
			return true;
		}else
			{
			return false;
			}
		}
	void log(String str1)
	{
		System.out.println(str1);
	}
	public void saveAs(String filename)
	{
		
		response.setHeader("Content-disposition","attachment; filename="+filename);	
	}
	public String replace(String str0)
	{
		String str1=str0;
		str1=str1.replaceAll("\\\\","\\\\\\\\");
		str1=str1.replaceAll("\"","\\\\\"");
		str1=str1.replaceAll("\t","\\\\\t");
		str1=str1.replaceAll("\r\n","\\\\r\\\\n");
		str1=str1.replaceAll("\n","\\\\n");
		return str1;
		}

	
}//class myjsp
